<?php
/**
 * ArticlesMenu is a widget displaying clipboard
 *
 */
class SClipboard extends Portlet
{
        public $title;
	private $_model=null;

	public function init()
	{
		$this->title=Yii::t('yii','Clipboard');	
		parent::init();
	}

	public function renderContent()
	{	
		$form=$this->loadModel();
		$form->user=Yii::app()->user->id;
		if(isset($_POST['Clipboard']))
		{
			$form->attributes=$_POST['Clipboard'];
			$form->validate();
			$form->save();
		}
		$this->render('clipboard',array('form'=>$form));
		
	}
	
	/**
	 * Returns the data model based on the primary key given in the GET variable.
	 * If the data model is not found, an HTTP exception will be raised.
	 */
	private function loadModel()
	{
		if($this->_model===null)
		{
				$criteria ='user='.Yii::app()->user->id;
				$this->_model=Clipboard::model()->find($criteria);
			
			if($this->_model===null)
				$this->_model=new Clipboard;
		}
		return $this->_model;
	}
}
?>




